package main

type tester interface {
	test()
	string() string
	toStringer
}

type toStringer interface {
	toString() string
}

type data struct {

}
type node struct {
	data interface{ //匿名接口类型
		string() string
	}
}

func (*data) test() {

}

func (data) string() string{
	return "hi str"
}

func (data) toString() string {
    return "hi to str"
}

func main()  {
	var d data
	var t tester = &d
	var s toStringer = t //转换为子接口
	var nd interface{
		string() string
	} = data{}

	pp(t) //隐式转换为子接口
	t.test()
	println(t.string())
	println(t.toString())
	println(s.toString())

	n := node{data:nd}
	println(n.data.string())

	var t1,t2 interface{}
	println(t1 == nil,t2 == t1)

}

func pp(a toStringer)  {
	println(a.toString())
}